package cn.toolck.springmvc.business.controller;

import cn.toolck.springmvc.spring.annotation.MyAutowired;
import cn.toolck.springmvc.spring.annotation.MyController;
import cn.toolck.springmvc.spring.annotation.MyRequestMapping;
import cn.toolck.springmvc.spring.annotation.MySecurity;
import cn.toolck.springmvc.business.service.DemoService;

/**
 * @ClassName TestController
 * @Description 测试用的controller
 * @Author Toolck Rin
 * @Date 2021/2/24 14:19
 * @Version 1.0
 **/
@MyController
@MyRequestMapping("/test")
@MySecurity({"张三", "李四"})
public class TestController {
    @MyAutowired
    private DemoService demoService;

    @MyRequestMapping("/get1")
    @MySecurity({"张三"})
    public String get1(String username) {
        return demoService.get(getMethodName() + username);
    }

    @MyRequestMapping("/get2")
    public String get2(String username) {
        return demoService.get(getMethodName() + username);
    }

    private String getMethodName() {
        return Thread.currentThread().getStackTrace()[2].getMethodName();
    }

    public DemoService getDemoService() {
        return demoService;
    }

    public void setDemoService(DemoService demoService) {
        this.demoService = demoService;
    }
}
